{
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "# Numpy切片\n",
    "---"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 导入CSV"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[   0 2020   10   20  610    2    0]\n",
      " [   1 2021   11   21  611    7   14]\n",
      " [   2 2022   12   22  612    2    4]\n",
      " [   3 2023   13   23  603    8   16]\n",
      " [   4 2024   14   24  614    3    6]\n",
      " [   5 2025   15   25  615    7   14]]\n"
     ]
    }
   ],
   "source": [
    "path = \"../../testSheet.CSV\"\n",
    "t1 = np.loadtxt(path, delimiter=',', dtype='int')\n",
    "print(t1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 打印第3行\n",
    "- 第a行\n",
    "- t1[a-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[   2 2022   12   22  612    2    4]\n"
     ]
    }
   ],
   "source": [
    "print(t1[2])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 从头打印两条结果\n",
    "- 头a条结果\n",
    "- t1[:a]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[   0 2020   10   20  610    2    0]\n",
      " [   1 2021   11   21  611    7   14]]\n"
     ]
    }
   ],
   "source": [
    "print(t1[:2])\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 取不连续的行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[   0 2020   10   20  610    2    0]\n",
      " [   3 2023   13   23  603    8   16]\n",
      " [   4 2024   14   24  614    3    6]]\n"
     ]
    }
   ],
   "source": [
    "print(t1[[0, 3, 4]])\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 取列\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[   1 2021   11   21  611    7   14]\n"
     ]
    }
   ],
   "source": [
    "print(t1[1, :])\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[   2 2022   12   22  612    2    4]\n"
     ]
    }
   ],
   "source": [
    "print(t1[2, :])"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## [a,b,c]行a,b,c"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[   2 2022   12   22  612    2    4]\n",
      " [   5 2025   15   25  615    7   14]\n",
      " [   3 2023   13   23  603    8   16]]\n"
     ]
    }
   ],
   "source": [
    "print(t1[[2, 5, 3], :])"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## a:b 从a行(列)到b行(列)\n",
    "- a~b行\n",
    "- c~d列\n",
    "- 0 0 a 0 0 0 b 0 0\n",
    "- 0 0 0 0 0 0 0 0 0\n",
    "- c 0 1 0 0 0 0 0 0\n",
    "- 0 0 0 2 0 0 0 0 0\n",
    "- 0 0 0 0 3 0 0 0 0\n",
    "- d 0 0 0 0 4 0 0 0\n",
    "- 0 0 0 0 0 0 5 0 0"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[['1' '0' '0' '0']\n",
      " ['0' '2' '0' '0']\n",
      " ['0' '0' '3' '0']\n",
      " ['0' '0' '0' '4']\n",
      " ['0' '0' '0' '0']]\n",
      "<class 'numpy.ndarray'>\n",
      "<class 'numpy.ndarray'>\n"
     ]
    }
   ],
   "source": [
    "a = 2\n",
    "b = 6\n",
    "c = 2\n",
    "d = 5\n",
    "table1 = np.array([\n",
    "    [0, 0, 'a', 0, 0, 0, 'b', 0, 0],\n",
    "    [0, 0, 0, 0, 0, 0, 0, 0, 0],\n",
    "    ['c', 0, 1, 0, 0, 0, 0, 0, 0],\n",
    "    [0, 0, 0, 2, 0, 0, 0, 0, 0],\n",
    "    [0, 0, 0, 0, 3, 0, 0, 0, 0],\n",
    "    ['d', 0, 0, 0, 0, 4, 0, 0, 0],\n",
    "    [0, 0, 0, 0, 0, 0, 5, 0, 0]\n",
    "])\n",
    "\n",
    "print(table1[a:b + 1, c:d + 1])\n",
    "print(type(t1))\n",
    "print(type(table1))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "- a~b行\n",
    "- c~d列\n",
    "- 0 0 1 2 3 4 5 6 7 8 9*\n",
    "- 1 0 0 0 0 a 0 0 0 0 b 0 0 0 0\n",
    "- 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
    "- 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
    "- 4 c 0 0 0 ac 0 0 0 0 ab 0 0 0 0\n",
    "- 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
    "- 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
    "- 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
    "- 8 d 0 0 0 ad 0 0 0 0 bd 0 0 0 0\n",
    "- 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
    "- 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
    "- 11 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
    "\n",
    "### 先取列在取行\n",
    "print(table2[c:d+1,a:b+1])\n",
    "\n",
    "                列   行\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 0  0  0  0  4  0  0  0  0  9  0  0  0  0]\n",
      " [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0]\n",
      " [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0]\n",
      " [ 3  0  0  0 13  0  0  0  0 12  0  0  0  0]\n",
      " [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0]\n",
      " [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0]\n",
      " [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0]\n",
      " [ 7  0  0  0 14  0  0  0  0 21  0  0  0  0]\n",
      " [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0]\n",
      " [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0]\n",
      " [ 0  0  0  0  0  0  0  0  0  0  0  0  0  0]]\n",
      "[[13  0  0  0  0 12]\n",
      " [ 0  0  0  0  0  0]\n",
      " [ 0  0  0  0  0  0]\n",
      " [ 0  0  0  0  0  0]\n",
      " [14  0  0  0  0 21]]\n"
     ]
    }
   ],
   "source": [
    "a = 4\n",
    "b = 9\n",
    "c = 3\n",
    "d = 7\n",
    "ac = 13\n",
    "ab = 12\n",
    "ad = 14\n",
    "bd = 21\n",
    "table2 = np.array([0, 0, 0, 0, a, 0, 0, 0, 0, b, 0, 0, 0, 0,\n",
    "                   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
    "                   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
    "                   c, 0, 0, 0, ac, 0, 0, 0, 0, ab, 0, 0, 0, 0,\n",
    "                   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
    "                   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
    "                   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
    "                   d, 0, 0, 0, ad, 0, 0, 0, 0, bd, 0, 0, 0, 0,\n",
    "                   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
    "                   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
    "                   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])\n",
    "table2 = table2.reshape([11, 14])\n",
    "print(table2)\n",
    "print(table2[c:d + 1, a:b + 1])\n",
    "# np.savetxt(\"testSheet01.CSV\",table2)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[   0 2020   10]\n",
      " [   1 2021   11]\n",
      " [   2 2022   12]]\n"
     ]
    }
   ],
   "source": [
    "print(t1[0:3, 0:3])"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 10  20 610   2   0]\n",
      " [ 11  21 611   7  14]\n",
      " [ 12  22 612   2   4]\n",
      " [ 13  23 603   8  16]\n",
      " [ 14  24 614   3   6]\n",
      " [ 15  25 615   7  14]]\n"
     ]
    }
   ],
   "source": [
    "print(t1[:, 2:])\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 取多行和多列，取第三行，第四列的值\n",
    "### exp\n",
    "* a行b列 [a,b]\n",
    "* 3行4列 [2,3]"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "22\n",
      "<class 'numpy.int32'>\n"
     ]
    }
   ],
   "source": [
    "a = t1[2, 3]\n",
    "print(a)\n",
    "print(type(a))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 取多行和多列，第3行到第五行，第二列到第四列的结果\n",
    "\n",
    "\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "source": [
    "table3 = np.arange(100)\n",
    "table3 = table3.reshape(10, 10)\n",
    "print(table3)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "execution_count": 51,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 0  1  2  3  4  5  6  7  8  9]\n",
      " [10 11 12 13 14 15 16 17 18 19]\n",
      " [20 21 22 23 24 25 26 27 28 29]\n",
      " [30 31 32 33 34 35 36 37 38 39]\n",
      " [40 41 42 43 44 45 46 47 48 49]\n",
      " [50 51 52 53 54 55 56 57 58 59]\n",
      " [60 61 62 63 64 65 66 67 68 69]\n",
      " [70 71 72 73 74 75 76 77 78 79]\n",
      " [80 81 82 83 84 85 86 87 88 89]\n",
      " [90 91 92 93 94 95 96 97 98 99]]\n"
     ]
    }
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[21 22 23]\n",
      " [31 32 33]\n",
      " [41 42 43]]\n"
     ]
    }
   ],
   "source": [
    "print(table3[2:5, 1:4])"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 总结"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "44\n"
     ]
    }
   ],
   "source": [
    "print(table3[4, 4])"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 5  6  7  8  9]\n",
      " [15 16 17 18 19]\n",
      " [25 26 27 28 29]\n",
      " [35 36 37 38 39]\n",
      " [45 46 47 48 49]]\n"
     ]
    }
   ],
   "source": [
    "print(table3[:5, 5:])"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[55 56 57 58 59]\n"
     ]
    }
   ],
   "source": [
    "print(table3[5, 5:])"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ 0 59 12]\n"
     ]
    }
   ],
   "source": [
    "print(table3[[0, 5, 1], [0, 9, 2]])"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 2  4  6  8]\n",
      " [12 14 16 18]\n",
      " [22 24 26 28]\n",
      " [32 34 36 38]\n",
      " [42 44 46 48]\n",
      " [52 54 56 58]\n",
      " [62 64 66 68]\n",
      " [72 74 76 78]\n",
      " [82 84 86 88]\n",
      " [92 94 96 98]]\n"
     ]
    }
   ],
   "source": [
    "print(table3[:, 2::2])"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 1  4  7]\n",
      " [11 14 17]\n",
      " [21 24 27]\n",
      " [31 34 37]\n",
      " [41 44 47]\n",
      " [51 54 57]\n",
      " [61 64 67]\n",
      " [71 74 77]\n",
      " [81 84 87]\n",
      " [91 94 97]]\n"
     ]
    }
   ],
   "source": [
    "print(table3[:, 1::3])\n",
    "\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "---\n",
    "# numpy数值修改"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 0  1  2  3  4  5  6  7  8  9]\n",
      " [10 11 12 13 14 15 16 17 18 19]\n",
      " [20 21 22 23 24 25 26 27 28 29]\n",
      " [30 31 32 33 34 35 36 37 38 39]\n",
      " [40 41 42 43 44 45 46 47 48 49]\n",
      " [50 51 52 53 54 55 56 57 58 59]\n",
      " [60 61 62 63 64 65 66 67 68 69]\n",
      " [70 71 72 73 74 75 76 77 78 79]\n",
      " [80 81 82 83 84 85 86 87 88 89]\n",
      " [90 91 92 93 94 95 96 97 98 99]]\n"
     ]
    }
   ],
   "source": [
    "# table3[:,2::4]=0\n",
    "print(table3)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ True  True  True  True  True  True  True  True  True  True]\n",
      " [ True  True  True  True  True  True  True  True  True  True]\n",
      " [ True  True  True  True  True  True  True  True  True  True]\n",
      " [False False False False False False False False False False]\n",
      " [False False False False False False False False False False]\n",
      " [False False False False False False False False False False]\n",
      " [False False False False False False False False False False]\n",
      " [False False False False False False False False False False]\n",
      " [False False False False False False False False False False]\n",
      " [False False False False False False False False False False]]\n"
     ]
    }
   ],
   "source": [
    "print(table3 < 30)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23\n",
      " 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39]\n"
     ]
    }
   ],
   "source": [
    "print(table3[table3 < 40])"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "383407616\n"
     ]
    }
   ],
   "source": [
    "# lambda 表达式exp\n",
    "powFun = lambda a1, b1: a1 ** b1\n",
    "print(powFun(a, b))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### np.where用法"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[  0   0   0   0   0   0   0   0   0   0]\n",
      " [  0   0   0   0   0   0   0   0   0   0]\n",
      " [  0   0   0   0   0   0   0   0   0   0]\n",
      " [  0   0   0   0   0   0   0   0   0   0]\n",
      " [  0   0   0   0   0   0   0   0   0   0]\n",
      " [100 100 100 100 100 100 100 100 100 100]\n",
      " [100 100 100 100 100 100 100 100 100 100]\n",
      " [100 100 100 100 100 100 100 100 100 100]\n",
      " [100 100 100 100 100 100 100 100 100 100]\n",
      " [100 100 100 100 100 100 100 100 100 100]]\n"
     ]
    }
   ],
   "source": [
    "print(np.where(table3 < 50, 0, 100))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### clip用法"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[10 10 10 10 10 10 10 10 10 10]\n",
      " [10 11 12 13 14 15 16 17 18 19]\n",
      " [20 21 22 23 24 25 26 27 28 29]\n",
      " [30 31 32 33 34 35 36 37 38 39]\n",
      " [40 41 42 43 44 45 46 47 48 49]\n",
      " [50 51 52 53 54 55 56 57 58 59]\n",
      " [60 61 62 63 64 65 66 67 68 69]\n",
      " [70 71 72 73 74 75 76 77 78 79]\n",
      " [80 81 82 83 84 85 86 87 88 89]\n",
      " [90 90 90 90 90 90 90 90 90 90]]\n"
     ]
    }
   ],
   "source": [
    "print(table3.clip(10, 90))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 0  1  2  3  4  5  6  7  8  9]\n",
      " [10 11 12 13 14 15 16 17 18 19]\n",
      " [20 21 22 23 24 25 26 27 28 29]\n",
      " [30 31 32 33 34 35 36 37 38 39]\n",
      " [40 41 42 43 44 45 46 47 48 49]\n",
      " [50 51 52 53 54 55 56 57 58 59]\n",
      " [60 61 62 63 64 65 66 67 68 69]\n",
      " [70 71 72 73 74 75 76 77 78 79]\n",
      " [80 81 82 83 84 85 86 87 88 89]\n",
      " [90 91 92 93 94 95 96 97 98 99]\n",
      " [99 98 97 96 95 94 93 92 91 90]\n",
      " [89 88 87 86 85 84 83 82 81 80]\n",
      " [79 78 77 76 75 74 73 72 71 70]\n",
      " [69 68 67 66 65 64 63 62 61 60]\n",
      " [59 58 57 56 55 54 53 52 51 50]\n",
      " [49 48 47 46 45 44 43 42 41 40]\n",
      " [39 38 37 36 35 34 33 32 31 30]\n",
      " [29 28 27 26 25 24 23 22 21 20]\n",
      " [19 18 17 16 15 14 13 12 11 10]\n",
      " [ 9  8  7  6  5  4  3  2  1  0]]\n",
      "[[ 0  1  2  3  4  5  6  7  8  9 99 98 97 96 95 94 93 92 91 90]\n",
      " [10 11 12 13 14 15 16 17 18 19 89 88 87 86 85 84 83 82 81 80]\n",
      " [20 21 22 23 24 25 26 27 28 29 79 78 77 76 75 74 73 72 71 70]\n",
      " [30 31 32 33 34 35 36 37 38 39 69 68 67 66 65 64 63 62 61 60]\n",
      " [40 41 42 43 44 45 46 47 48 49 59 58 57 56 55 54 53 52 51 50]\n",
      " [50 51 52 53 54 55 56 57 58 59 49 48 47 46 45 44 43 42 41 40]\n",
      " [60 61 62 63 64 65 66 67 68 69 39 38 37 36 35 34 33 32 31 30]\n",
      " [70 71 72 73 74 75 76 77 78 79 29 28 27 26 25 24 23 22 21 20]\n",
      " [80 81 82 83 84 85 86 87 88 89 19 18 17 16 15 14 13 12 11 10]\n",
      " [90 91 92 93 94 95 96 97 98 99  9  8  7  6  5  4  3  2  1  0]]\n"
     ]
    }
   ],
   "source": [
    "table4 = np.arange(99, -1, -1)\n",
    "# print(table4)\n",
    "table4 = table4.reshape(10, 10)\n",
    "outTable = np.vstack((table3, table4))\n",
    "print(outTable)\n",
    "print(np.hstack((table3, table4)))\n",
    "# print(table4)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "success\n"
     ]
    }
   ],
   "source": [
    "# np.savetxt('outTable.CSV',outTable,delimiter=\",\",fmt='%2d')\n",
    "print(\"success\")"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 0  1  2  3  4  5  6  7  8  9]\n",
      " [50 51 52 53 54 55 56 57 58 59]\n",
      " [20 21 22 23 24 25 26 27 28 29]\n",
      " [30 31 32 33 34 35 36 37 38 39]\n",
      " [40 41 42 43 44 45 46 47 48 49]\n",
      " [10 11 12 13 14 15 16 17 18 19]\n",
      " [60 61 62 63 64 65 66 67 68 69]\n",
      " [70 71 72 73 74 75 76 77 78 79]\n",
      " [80 81 82 83 84 85 86 87 88 89]\n",
      " [90 91 92 93 94 95 96 97 98 99]]\n"
     ]
    }
   ],
   "source": [
    "table3[[5, 1], :] = table3[[1, 5], :]\n",
    "print(table3)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 0  5  2  3  4  1  6  7  8  9]\n",
      " [50 55 52 53 54 51 56 57 58 59]\n",
      " [20 25 22 23 24 21 26 27 28 29]\n",
      " [30 35 32 33 34 31 36 37 38 39]\n",
      " [40 45 42 43 44 41 46 47 48 49]\n",
      " [10 15 12 13 14 11 16 17 18 19]\n",
      " [60 65 62 63 64 61 66 67 68 69]\n",
      " [70 75 72 73 74 71 76 77 78 79]\n",
      " [80 85 82 83 84 81 86 87 88 89]\n",
      " [90 95 92 93 94 91 96 97 98 99]]\n"
     ]
    }
   ],
   "source": [
    "table3[:, [1, 5]] = table3[:, [5, 1]]\n",
    "print(table3)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[100 102 104 106 108 110 112 114 116 118]\n",
      " [120 122 124 126 128 130 132 134 136 138]\n",
      " [140 142 144 146 148 150 152 154 156 158]\n",
      " [160 162 164 166 168 170 172 174 176 178]\n",
      " [180 182 184 186 188 190 192 194 196 198]\n",
      " [200 202 204 206 208 210 212 214 216 218]\n",
      " [220 222 224 226 228 230 232 234 236 238]\n",
      " [240 242 244 246 248 250 252 254 256 258]\n",
      " [260 262 264 266 268 270 272 274 276 278]\n",
      " [280 282 284 286 288 290 292 294 296 298]]\n"
     ]
    }
   ],
   "source": [
    "table5 = np.arange(100, 300, 2)\n",
    "table5 = table5.reshape(10, 10)\n",
    "print(table5)\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[  0   5   2   3   4   1 160 180   8   9]\n",
      " [ 50  55  52  53  54  51 162 182  58  59]\n",
      " [ 20  25  22  23  24  21 164 184  28  29]\n",
      " [ 30  35  32  33  34  31 166 186  38  39]\n",
      " [ 40  45  42  43  44  41 168 188  48  49]\n",
      " [ 10  15  12  13  14  11 170 190  18  19]\n",
      " [ 60  65  62  63  64  61 172 192  68  69]\n",
      " [ 70  75  72  73  74  71 174 194  78  79]\n",
      " [ 80  85  82  83  84  81 176 196  88  89]\n",
      " [ 90  95  92  93  94  91 178 198  98  99]]\n"
     ]
    }
   ],
   "source": [
    "table3[:, 6:8] = table5[3:5, :].T\n",
    "print(table3)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'np' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001B[1;31m---------------------------------------------------------------------------\u001B[0m",
      "\u001B[1;31mNameError\u001B[0m                                 Traceback (most recent call last)",
      "\u001B[1;32m<ipython-input-1-2bfcaed59973>\u001B[0m in \u001B[0;36m<module>\u001B[1;34m\u001B[0m\n\u001B[0;32m      1\u001B[0m \u001B[1;33m\u001B[0m\u001B[0m\n\u001B[1;32m----> 2\u001B[1;33m \u001B[0mzero_data\u001B[0m \u001B[1;33m=\u001B[0m \u001B[0mnp\u001B[0m\u001B[1;33m.\u001B[0m\u001B[0mzeros\u001B[0m\u001B[1;33m(\u001B[0m\u001B[1;33m(\u001B[0m\u001B[0mtable5\u001B[0m\u001B[1;33m.\u001B[0m\u001B[0mshape\u001B[0m\u001B[1;33m[\u001B[0m\u001B[1;36m0\u001B[0m\u001B[1;33m]\u001B[0m\u001B[1;33m,\u001B[0m \u001B[1;36m1\u001B[0m\u001B[1;33m)\u001B[0m\u001B[1;33m)\u001B[0m\u001B[1;33m.\u001B[0m\u001B[0mastype\u001B[0m\u001B[1;33m(\u001B[0m\u001B[0mint\u001B[0m\u001B[1;33m)\u001B[0m\u001B[1;33m\u001B[0m\u001B[1;33m\u001B[0m\u001B[0m\n\u001B[0m\u001B[0;32m      3\u001B[0m \u001B[0mprint\u001B[0m\u001B[1;33m(\u001B[0m\u001B[0mzero_data\u001B[0m\u001B[1;33m)\u001B[0m\u001B[1;33m\u001B[0m\u001B[1;33m\u001B[0m\u001B[0m\n\u001B[0;32m      4\u001B[0m \u001B[0mones_data\u001B[0m \u001B[1;33m=\u001B[0m \u001B[0mnp\u001B[0m\u001B[1;33m.\u001B[0m\u001B[0mones\u001B[0m\u001B[1;33m(\u001B[0m\u001B[1;33m(\u001B[0m\u001B[0mtable5\u001B[0m\u001B[1;33m.\u001B[0m\u001B[0mshape\u001B[0m\u001B[1;33m[\u001B[0m\u001B[1;36m0\u001B[0m\u001B[1;33m]\u001B[0m\u001B[1;33m,\u001B[0m\u001B[1;36m1\u001B[0m\u001B[1;33m)\u001B[0m\u001B[1;33m)\u001B[0m\u001B[1;33m.\u001B[0m\u001B[0mastype\u001B[0m\u001B[1;33m(\u001B[0m\u001B[0mint\u001B[0m\u001B[1;33m)\u001B[0m\u001B[1;33m\u001B[0m\u001B[1;33m\u001B[0m\u001B[0m\n\u001B[0;32m      5\u001B[0m \u001B[0mprint\u001B[0m\u001B[1;33m(\u001B[0m\u001B[0mones_data\u001B[0m\u001B[1;33m)\u001B[0m\u001B[1;33m\u001B[0m\u001B[1;33m\u001B[0m\u001B[0m\n",
      "\u001B[1;31mNameError\u001B[0m: name 'np' is not defined"
     ]
    }
   ],
   "source": [
    "# zero_data = np.zeros((table5.shape[0], 1)).astype(int)\n",
    "# print(zero_data)\n",
    "# ones_data = np.ones((table5.shape[2],1)).astype(int)\n",
    "# print(ones_data)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [
    "import pandas as pd\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}